<template>
	<div class="index">
		<div class="shangh " v-if="UserInfo_data.channel_id===undefined&&token!=''">
			<router-link to="/SMreg">
				<div class="link-btn">商户入驻</div>
			</router-link>
		</div>
		<div class="shangh " v-if="UserInfo_data.channel_id===0&&token!=''">
			<router-link to="/SMreg">
				<div class="link-btn">商户入驻</div>
			</router-link>
		</div>
		<img src="../assets/img/index/index-1.png" />
		<img src="../assets/img/index/index-2.png" />
		<img src="../assets/img/index/index-3.png" />
		<img src="../assets/img/index/index-4.png" />
		<div style="width: 100%;background: #fff;">

			<div class="index-5">
				<div class="content">
					<div class="list">
						<div class="row">
							<img class="codeimg" src="../assets/img/index/code-xcx1.png" />
							<p>自游驾小程序会员版</p>
						</div>
						<div class="row">
							<img class="codeimg" src="../assets/img/index/code-xcx2.png" />
							<p>自游驾小程序商户版</p>
						</div>
					</div>
					<div class="list">
						<div class="row">
							<img class="codeimg" src="../assets/img/index/code-gzh2.png" />
							<p>丁丁猫服务号</p>
						</div>
						<div class="row">
							<img class="codeimg" src="../assets/img/index/code-gzh1.png" />
							<p>自游驾订阅号</p>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
</template>

<script>
	import Cookie from "../fetch/cookie.js"
	import {
		mapGetters,
		mapActions
	} from 'vuex';

	export default {
		data() {
			return {
				name: "张三",
				num: 0,
			}
		},
		computed: {
			...mapGetters([
				'token',
				'UserInfo_data',
				'login_register_start'
			])
		},
		mounted() {},
		created() {
			if (this.$api.getQueryString("token") != null) {
				this.setToken(this.$api.getQueryString("token"))
				Cookie.Cookieset('token', this.$api.getQueryString("token"), "7d")
				this.UserInfo();
			} else {
				if (Cookie.Cookieget("token") != null) {
					this.setToken(Cookie.Cookieget("token"))
					this.UserInfo();
				} else {
					if (this.login_register_start != 'wx_inputAuthorize') {
						this.$router.push("/LoginIndex")
					}
				}
			}
		},
		methods: {
			...mapActions({
				setToken: 'setToken',
				getUserInfo: 'getUserInfo',
				getheaderIndex: "getheaderIndex"
			}),

			UserInfo() {
				this.$api.GetUserInfo({
						token: this.token
					})
					.then(res => {
						if (res.code === 200) {
							this.getUserInfo(res.result)
							if (this.UserInfo_data.channel_id != undefined || this.UserInfo_data.channel_id != 0) {
								for (var i = 0; i < this.UserInfo_data.status.length; i++) {
									if (this.UserInfo_data.status[i] === '3') {
										this.$router.push('/Oticket');
									} 
									else if (this.UserInfo_data.status[i] === '7') {
										this.$router.push('/');
									}
									else {
										this.$router.push('/index');
									}
								}
							}
						}
						if (res.code === 310) {
								this.$alert(res.meg, '提示', {
								confirmButtonText: '确定',
								callback: action => {
									this.$router.push("/LoginIndex");
									Cookie.Cookiedel("token")
									this.setToken("");
								}
							})
						}
					})
			},
		}
	}
</script>

<style scoped lang="less">
	.index {
		.shangh {
			width: 100%;
			position: absolute;
			top: 300px;
			display: flex;
			justify-content: center;

			.link-btn {
				cursor: pointer;
				padding: 10px 50px;
				box-sizing: border-box;
				font-size: 30px;
				font-weight: bold;
				color: #fff;
				background: #ff9a03;
				border-radius: 10px;
			}
		}

		img {
			width: 100%;
			display: block;
			margin: auto;
		}

		.index-5 {
			width: 1100px;
			height: 215px;
			margin: auto;
			background: #fff;

			.content {
				margin: auto;
				width: 850px;
				height: 100%;
				display: flex;
				justify-content: center;
				align-items: center;

				.list {
					width: 50%;
					display: flex;
					justify-content: center;

					.row {
						padding: 30px 25px;
						box-sizing: border-box;
						font-size: 12px;
						color: #000;

						.codeimg {
							width: 110px;
							height: 110px;
							margin-bottom: 15px;
						}
					}
				}
			}
		}
	}
</style>
